import { createRouter, createWebHashHistory } from 'vue-router'
const Index = () => import("../view/Index.vue");
const test = () => import("../view/test.vue");

const routes = [
    {
        path: "/",
        name: "index",
        component: Index
    },
    {
        path: "/test",
        name: "test",
        component: test
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    if(to.name) {
        next()
    }else {
        next({
            path: '/',
        })
    }

})

export function setupRouter(app) {
    app.use(router)
}